<?php
##############################################
#
#   用户会员
# @ Time : 2017-2-5 - 下午11:05:30
# @ Author : JiangYongWei <1085562810@qq.com>
# @ Encoding : UTF-8 language : PHP
#
##############################################


namespace Home\Model;

class UserModel extends IndexBaseModel{
	/*用户表  */
	protected $tableName = 'user';
	
	/**
	 * 验证用户是否存在
	 * @param string $field
	 * @param string $value
	 * return int
	 */
	public function check($field, $value){
		return $this -> where("$field = '$value'") -> count(); 
	}
	
	/**
	 * 注册用户
	 * @param array $data
	 * @return int
	 */
	public function regUser($data){
		return $this -> add($data);
	}
	
	/**
	 * 获取用户
	 * @param array $data
	 * return array
	 */
	public function getUser($data){
		$fields = array('uid', 'uname', 'email');
		return $this -> where("uname = '{$data['username']}' or email = '{$data['username']}' and password = '{$data['password']}'")
					 ->field($fields) -> find();
	}
	
	
}
